/**
 *
 */
package de.cbf.cam.dsa.person.entities;

import java.util.ArrayList;
import java.util.List;

import de.cbf.cam.dsa.rcp.model.entities.PerkDSA;
import de.cbf.util.uuidheader.entities.NamedEntity;
import de.cbf.util.uuidheader.entities.UUIDHeader;
import de.cbf.util.uuidheader.exceptions.EntityMergeException;

/**
 * @author Surfer
 *
 */
public class PersonSpecialsDSA extends UUIDHeader{

	public static final String ATTRIBUTE_ROYAL = PerkDSA.ATTRIBUTE_ROYAL;

	protected List<PerkDSA> perks;

	public PersonSpecialsDSA() {
		super();
		perks = new ArrayList<PerkDSA>();

	}


	@Override
	protected void doMergeDataFrom(UUIDHeader entity, boolean i_am_older)
			throws EntityMergeException {

	}

	public List<PerkDSA> getPerks() {
		return perks;
	}

	public void setPerks(List<PerkDSA> perks) {
		this.perks.clear();
		this.perks.addAll(perks);
	}


	public boolean containsAttribute(String string) {
		for (PerkDSA perk : perks) {
			if(perk.hasAttribute(string)){
				return true;
			}
		}
		return false;
	}


	public String specialString() {
		StringBuffer buffer = new StringBuffer();
		for (PerkDSA perk : perks) {
			UUIDHeader header = perk.getEntity();
			if (header instanceof NamedEntity) {
				NamedEntity namedEntity = (NamedEntity) header;
				buffer.append(namedEntity.getName()+",");
			}
		}
		buffer.deleteCharAt(buffer.length()-1);//remove end ","
		return buffer.toString();
	}
}
